<template>
  <div class="student">
    <h1>学生姓名:{{name}}</h1>
    <h2>学生年龄:{{age}}</h2>
    <button @click="sendStudentNameToSchool">发送学生姓名给School组件</button>
</div>
</template>

<script>
    export default {
        name: "StudentInfo",
        data() {
            return {
                name: "张三",
                age: 18
            }
        },
        methods: {
            sendStudentNameToSchool() {
                this.$bus.$emit("hello", this.name);
            }
        },
        mounted() {
            // console.log("Student", this.x);
        }
        
    }
</script>

<style scoped>
    .student{
        background-color: orange;
    }
</style>